// 基础请求参数类型，包含txt2img和img2img的公共参数
export interface BaseRequest {
  // 公共必填参数
  prompt: string;
  negative_prompt: string;
  sampler_name: string;
  batch_size: number;
  n_iter: number;
  steps: number;
  cfg_scale: number;
  width: number;
  height: number;
  
  // 公共可选参数
  styles?: string[];
  seed?: number;
  subseed?: number;
  subseed_strength?: number;
  seed_resize_from_h?: number;
  seed_resize_from_w?: number;
  scheduler?: string;
  restore_faces?: boolean;
  tiling?: boolean;
  do_not_save_samples?: boolean;
  do_not_save_grid?: boolean;
  eta?: number;
  s_min_uncond?: number;
  s_churn?: number;
  s_tmin?: number;
  s_tmax?: number;
  s_noise?: number;
  override_settings?: Record<string, any>;
  override_settings_restore_afterwards?: boolean;
  refiner_checkpoint?: string;
  refiner_switch_at?: number;
  disable_extra_networks?: boolean;
  firstpass_image?: string;
  comments?: Record<string, any>;
  sampler_index?: string;
  script_name?: string;
  script_args?: any[];
  alwayson_scripts?: Record<string, any>;
  send_images?: boolean;
  save_images?: boolean;
  force_task_id?: string;
  infotext?: string;
}

// 文本到图像接口的请求参数类型
export interface Txt2ImgRequest extends BaseRequest {
  // txt2img特有参数
  enable_hr?: boolean;
  hr_scale?: number;
  hr_upscaler?: string;
  hr_second_pass_steps?: number;
  hr_resize_x?: number;
  hr_resize_y?: number;
  hr_checkpoint_name?: string;
  hr_sampler_name?: string;
  hr_scheduler?: string;
  hr_prompt?: string;
  hr_negative_prompt?: string;
  firstphase_width?: number;
  firstphase_height?: number;
  denoising_strength?: number;
}

// 图像到图像接口的请求参数类型
export interface Img2ImgRequest extends BaseRequest {
  // img2img特有必填参数
  init_images: string[];
  denoising_strength: number;
  
  // img2img特有可选参数
  resize_mode?: number;
  image_cfg_scale?: number;
  mask?: string;
  mask_blur?: number;
  mask_blur_x?: number;
  mask_blur_y?: number;
  mask_round?: boolean;
  inpainting_fill?: number;
  inpaint_full_res?: boolean;
  inpaint_full_res_padding?: number;
  inpainting_mask_invert?: number;
  initial_noise_multiplier?: number;
  latent_mask?: string;
  include_init_images?: boolean;
}

// 单张图片后期处理接口的请求参数类型
export interface ExtraSingleImageRequest {
  // 必填参数
  image: string;
  
  // 可选参数
  resize_mode?: number;
  show_extras_results?: boolean;
  gfpgan_visibility?: number;
  codeformer_visibility?: number;
  codeformer_weight?: number;
  upscaling_resize?: number;
  upscaling_resize_w?: number;
  upscaling_resize_h?: number;
  upscaling_crop?: boolean;
  upscaler_1?: string;
  upscaler_2?: string;
  extras_upscaler_2_visibility?: number;
  upscale_first?: boolean;
}

// 响应类型和错误类型保持不变
export interface SDSuccessResponse {
  images: string[];
  parameters: Record<string, any>;
  info: string;
}

export interface SDErrorResponse {
  error: string;
  detail?: string;
  status?: number;
}